<template>
    <div>
        <van-form>
            <div v-for="(j,pindex) in list">
                <van-field :label='i.label+index' v-model="value[pindex+i.key+pindex]" v-for="(i,index) in j"  />
            </div>
            <van-button @click="add" color="linear-gradient(to right, #ff6034,#7232dd)">+</van-button><br><br>
            <van-button @click="save" color="linear-gradient(to left, #ff6034,#7232dd)">提交</van-button>
        </van-form>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                frorm:{},
                list:[[{'label':'名称','key':'name'},{'label':'类型','key':'type'},{'label':'值','key':'value'}]],
                value:'',
                number:1
            }
        },
        methods:{
            add(){
                this.list.push([{'label':'名称','key':'name'},{'label':'类型','key':'type'},{'label':'值','key':'value'}])
                this.number+=1
            },
            save(){
                var l =[]
                for (var i=0;i<this.number;i++){
                    var name=i+'name'+i
                    var type=i+'type'+i
                    var v = i+'value'+i
                    var dict={'name':this.value[name],'vaule':this.value[v],'type':this.value[type]}
                    l.push(dict)
                }
                console.log(l)
            }
        }
    }
</script>

<style scoped>

</style>